package com.pingan.config;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.IPing;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.PingUrl;
import com.netflix.loadbalancer.RandomRule;

@Configuration
public class MovieConfiguration {
	@Autowired IClientConfig config;
	
//	@Bean
//    public IPing ribbonPing(IClientConfig config) {
//		System.out.println("start ribbonPing:" + new Date().toLocaleString());
//        return new PingUrl();
//    }
	
	@Bean
	@ConditionalOnMissingBean
	public IRule ribbonRule(IClientConfig config) {
		System.out.println("start ribbonRule:" + new Date().toLocaleString());
		return new RandomRule();
	}
}
